﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint.Administration;

namespace CrossSiteCollectionSearchConfigurator
{
    [CLSCompliant(false)]
    public class SearchSettingsPropogatorJob : SPJobDefinition
    {
        public SearchSettingsPropogatorJob()
            : base()
        {
        }
        public SearchSettingsPropogatorJob(String jobName, SPService service, SPServer server, SPJobLockType targetType)
            : base(jobName, service, server, targetType)
        {
            this.Title = jobName;
        }

        public SearchSettingsPropogatorJob(String jobName,
                                            SPWebApplication application,
                                            SPServer server,
                                            SPJobLockType targetType)
            : base(jobName, application, server, targetType)
        {
            this.Title = jobName;
        }

        public SearchSettingsPropogatorJob(String jobName, SPWebApplication webApp)
            : base(jobName, webApp, null, SPJobLockType.ContentDatabase)
        {
            this.Title = jobName;
        }

        /// <summary>
        /// This method is executed whenever the timer job fires.
        /// </summary>
        /// <param name="targetInstanceId"></param>
        public override void Execute(Guid targetInstanceId)
        {
            SearchSettingsPropogatorEngine.RunEngine(this.WebApplication);
        }
    }
}
